package com.zxbit.uangstore.business;

import com.alibaba.android.arouter.launcher.ARouter;
import com.zxbit.uangstore.base.BaseResponse;
import com.zxbit.uangstore.cache.UserInfo;
import com.zxbit.uangstore.constant.Constant;

import io.reactivex.functions.Consumer;

public abstract class CustomConsumer<T extends BaseResponse> implements Consumer<T> {

    @Override
    public void accept(T t) throws Exception {

        if (t.getStatus() == Constant.LOGIN_TIMEOUT) {//token 会过期
            ARouter.getInstance().build(RouterMap.LOGIN_METNOD_PAGE).navigation();
            UserInfo.logout();
            return;
        }

        processCommonData(t);
    }
    /**
     * 处理正常数据
     */
    protected abstract void processCommonData(T t);
}
